#include<bits/stdc++.h>
using namespace std;
int main() {
    char op;
    int n;
    cin >> op >> n;
    string line;
    vector<string> vec;
    getchar();
    for (int i = 0; i < n; i++) {
        getline(cin, line);
        vec.push_back(line);
    }
    int idx;
    for (idx = 0; idx <= vec.size() / 2; idx++) {
        if (vec[idx] != vec[vec.size() - idx - 1]) break;
    }
    if (idx < vec.size() / 2) {
        for (int j = vec.size() - 1; j >= 0; j--) {
            for (int i = vec[j].length() - 1; i >= 0 ; i--) {
                if (vec[j][i] == ' ') cout << " ";
                else cout << op;
            }
            cout << endl;
        }
    } else {
        cout << "bu yong dao le" << endl;
        for (auto& v : vec) {
            for (int j = 0; j < v.length(); j++) {
                if (v[j] == ' ') cout << " ";
                else cout << op;
            }
            cout << endl;
        }
    }
    
    return 0;
}